jQuery(function($){
  $("select[name='store_staff[store_department_id]']").on('change', function(){
    var id = $(this).val();
    $.ajax({
      url: "/api/store_departments/"+ id,
      success: function(data){
        html = ""
        data.positions.forEach(function(item){
          html += "<option value="+ item.id  +">"+ item.name +"</option>"
        })
        $("select[name='store_staff[store_position_id]']").html(html)
      }
    })
  });

})
